package mapred.example;

import java.io.IOException;
import java.util.Iterator;

import mapred.base.TextReducer;

import org.apache.hadoop.io.Text;

import util.FeatureMap;

public class FeatureMap_Sum_Reducer extends TextReducer {

    private static String delim = null;

    @Override
    public void reduce(Text key, Iterator<Text> values) throws IOException {
        FeatureMap map = FeatureMap.createNewFeatureMap(delim);
        while (values.hasNext()) {
            map.add(FeatureMap.parse(values.next().toString(), delim));
        }
        this.output(key, new Text(map.toString()));
    }

    @Override
    public void setUp() {
        delim = this.getConfig("delim");
    }

    @Override
    public void tearDown() throws IOException {
    }

}